#include "multiline.h"

CxQML::Multiline::Multiline() {

}


CxQML::Multiline::Multiline(CxQML::Point* points, int quant, bool isClosed):
    _isClosed(isClosed)
{
    for (int i = 0; i < quant; i++)
        insertLastPoint(*(points + i));
}

CxQML::Multiline::Multiline(CxQML::LineSegment* segments, int quant, bool isClosed):
    _isClosed(isClosed)
{
    for (int i = 0; i < quant; i++) {
        insertLastPoint((*(segments + i)).firstPoint());
        insertLastPoint((*(segments + i)).lastPoint());
    }
}

int CxQML::Multiline::necessaryPointsQuant() const
{
    return 2;
}

bool CxQML::Multiline::isClosed() const
{
    return _isClosed && getPoints().size() > 2;
}

void CxQML::Multiline::setIsClosed(bool isClosed)
{
    _isClosed = isClosed;
}

QString CxQML::Multiline::className() const
{
    return "Multiline";
}

CxQML::Multiline::operator QString()
{
    QList<Point> points = getPoints();

    QString result = "Mutiline(";

    for (int i = 0; i < points.size(); i++) {
        result += QString(points[i]);
    }

    result += ")";

    return result;
}

